/*
 * qc slave mode data control.
 * Copyright (c) 2012  everyone
 * All rights reserved.
 * no limite
 */
#include "qcom.h"
#include "sys_task.h"

uu16 hdat[16];
/*******************************************************************************
 * @brief  reg_hold_read
 * \param[in] Index : data address
 * @return  data
 * @ Pass/ Fail criteria: none
 *****************************************************************************/
uint16_t qc_reg_get(uint16_t Index)
{
	word_tt Val;
	Val.uval = 0;

	hdat[4]++;

	if (Index < 16)
	{
		Val.uval = hdat[Index];
	}
	else
	{

	}
	return Val.uVal;
}

/*******************************************************************************
 * @brief  reg_hold_write
 * \param[in] Index : data address
 * \param[in] Val : data
 * @return  data
 * @ Pass/ Fail criteria: none
 *******************************************************************************/
void qc_reg_set(uint16_t Index, uint16_t Val)
{
	if (Index < 16)
	{
		hdat[Index] = Val;
	}

}

/*******************************************************************************
 * @brief  reg_input_read
 * \param[in] Index : data address
 * @return  data
 * @ Pass/ Fail criteria: none
 *****************************************************************************/
uint16_t qc_input_get(uint16_t Index)
{
	word_tt Val;
	Val.uval = 0;

	hdat[4]++;

	if (Index < 16)
	{
		Val.uval = hdat[Index];
	}
	else
	{

	}
	return Val.uVal;
}

/*******************************************************************************
 * @brief  reg_coil_write
 * \param[in] Index : data address
 * \param[in] Val : data
 * @return  data
 * @ Pass/ Fail criteria: none
 *******************************************************************************/
uu8 coil_reg[16];

void qc_coil_dat_set(uu16 Bindex, uu8 dat)
{
	if (Bindex < 16)
		coil_reg[Bindex] = dat;
}

/*******************************************************************************
 * @brief  reg_coil_read
 * \param[in] Index : data address
 * @return  data
 * @ Pass/ Fail criteria: none
 *****************************************************************************/
uu8 qc_coil_dat_get(uu16 Bindex)
{
	if (Bindex < 16)
		return coil_reg[Bindex];
	else
		return 0;
}
